package com.akl.ssmspringboot.thread;

/**
 * @ClassName: Bank
 * @Description TODO
 * @Author guoxy
 * @Date 2019/4/19 0019
 * @Version 1.0
 */
public class Bank {

    private static int money;

    public int getMoney() {
        return money;
    }

    public void saveMoney(int m) {
        synchronized (this) {
            System.out.println("存钱后的总金额：" + (money += m));
        }
    }

    public void drawMoney(int m) {
        synchronized (this) {
            Bank bank = new Bank();
            if (bank.getMoney() <= 0) {
                System.out.println("余额不足，请充值！");
            } else {
                System.out.println("取钱后剩的总金额：" + (money -= m));
            }
        }
    }
}